# Contributor: Pedro Filipe <xpecex@outlook.com>
# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Contributor: omni <omni+alpine@hack.org>
# Maintainer: ScrumpyJack <scrumpyjack@st.ilet.to>
pkgname=opencpn
pkgver=5.8.4
pkgrel=0
pkgdesc="OpenCPN is a cross platform electronic navigation system"
url="https://opencpn.org/"
arch="all"
license="GPL-2.0-or-later AND MIT"
depends="gpsd"
makedepends="
	cmake
	curl-dev
	elfutils-dev
	eudev-dev
	glew-dev
	glu-dev
	jasper-dev
	libarchive-dev
	libexif-dev
	libusb-dev
	linux-headers
	lsb-release
	lz4-dev
	musl-legacy-error
	portaudio-dev
	rapidjson-dev
	samurai
	sqlite-dev
	tinyxml-dev
	wxwidgets-dev
	"
subpackages="$pkgname-doc $pkgname-lang"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/OpenCPN/OpenCPN/archive/refs/tags/Release_$pkgver.tar.gz
	gcc12.patch
	rapidjson.patch
	"
builddir="$srcdir/OpenCPN-Release_$pkgver"
options="!check" # todo

build() {
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DOCPN_BUNDLE_GSHHS=CRUDE \
		-DOCPN_BUNDLE_TCDATA=ON \
		-DOCPN_USE_BUNDLED_LIBS=OFF \
		-DOCPN_BUILD_TEST="$(want_check && echo ON || echo OFF)" \
		-DOCPN_BUNDLE_DOCS=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
08231d95ca80a5e6b85b279be2912d3e9f390f879a780823f8ee9c64371eb0605484f697328217027c7caf18cb1151b617d42d22951672c1a9508750e97f109a  opencpn-5.8.4.tar.gz
d2cc0b3212258f8c086607fc9e6b8ed47172c53fcf33f401addecbdd3215199ea6900c44979e66083dca39ae0610bdf4256604edae47adccaac4df39cfa775db  gcc12.patch
401f74070e3a3f220a547e81b23eefe78b76b39391affd4af58566393890b2565cc3725736fcbf354868c85aebbff2169e049ec92f6836b04ba197ff7dbd64fb  rapidjson.patch
"
